import 'package:flutter/material.dart';

class BuildInfo with ChangeNotifier{
    String id; // 10003
    String name; // 6号楼
    bool isSelected = false;

    BuildInfo({this.id, this.name});

    bool isValid(){
        return id?.isNotEmpty == true;
    }

    notifyChanged() => notifyListeners();

    /// 工程构造方法，允许返回一个对象
    factory BuildInfo.fromJson(Map<String, dynamic> json) {
        return BuildInfo(
            id: json['id'],
            name: json['name'],
        );
    }

    Map<String, dynamic> toJson() {
        final Map<String, dynamic> data = new Map<String, dynamic>();
        data['id'] = this.id;
        data['name'] = this.name;
        return data;
    }
}